package com.aliang.shopping.model.converter;

import com.aliang.shopping.model.dto.address.AddressInsertDTO;
import com.aliang.shopping.model.dto.address.AddressUpdateDTO;
import com.aliang.shopping.model.dto.common.UpdateStatusDTO;
import com.aliang.shopping.model.po.Address;
import com.aliang.shopping.model.vo.address.AddressVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;


/**
 * 地址数据转换器
 */
@Mapper(componentModel = "Spring")
public interface OrdersItemConverter {

    /**
     * 将地址插入数据传输对象转换为地址实体
     *
     * @param insertDTO
     * @return
     */
    Address toPoByInsertDTO(AddressInsertDTO insertDTO);

    /**
     * 将地址更新数据传输对象转换为地址实体
     *
     * @param updateDTO
     * @return
     */
    Address toPoByUpdateDTO(AddressUpdateDTO updateDTO);


    /**
     * 将地址对象转换为地址视图实体
     *
     * @param address
     * @return
     */
    AddressVO toVoByPo(Address address);

    List<AddressVO> toVoByPoList(List<Address> addressList);


    /**
     * 将地址更新状态数据传输对象转换为地址实体
     *
     * @param updateDTO
     * @return
     */
    @Mapping(target = "orderNum", source = "status")
    Address toPoByUpdateStaticDTO(UpdateStatusDTO updateDTO);

    List<Address> toPoByUpdateStaticDTOList(List<UpdateStatusDTO> updateDTOList);

}
